package com.web.hotel.po.mapper;

import com.web.hotel.po.Hotel;
import org.springframework.jdbc.core.RowMapper;

import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Timestamp;

/**
 * Created by chen on 2017/3/12.
 */
public class HotelMapper implements RowMapper<Hotel> {

    public Hotel mapRow(ResultSet resultSet, int i) throws SQLException {
        Hotel hotel = new Hotel();
        hotel.setHotelId(resultSet.getInt("hotelId"));
        hotel.setCityId(resultSet.getInt("cityId"));
        hotel.setHotelName(resultSet.getString("hotelName"));
        hotel.setHotelImg(resultSet.getString("hotelImg"));
        hotel.setHotelCode(resultSet.getString("hotelCode"));
        hotel.setHotelType(resultSet.getString("hotelType"));
        hotel.setCreateUser(resultSet.getString("createUser"));
        Timestamp timestamp = resultSet.getTimestamp("createTime");
        if (timestamp != null)
            hotel.setCreateTime(new java.util.Date(timestamp.getTime()));
        return hotel;
    }
}
